/*
 * --------------------------------------------------------------
 * Copyright ©  2015 Hangzhou DtDream Technologies Co.,Ltd.
 * --------------------------------------------------------------
 *      Product: 协同数治
 *  Module Name: design
 * Date Created: 2023/1/31
 *  Description: TODO
 * --------------------------------------------------------------
 * Modification History
 * DATE            NAME            Description
 * --------------------------------------------------------------
 * 2023/1/31       yewj            TODO
 * --------------------------------------------------------------
 */

package com.dtdream.pattern.prototype.deepclone;

/**
 * TODO
 *
 * @Author: yewj
 **/
public class Client {
    public static void main(String[] args) throws CloneNotSupportedException {
        DeepProtoType p = new DeepProtoType();
        p.name = "张飞";
        p.target = new DeepCloneableTarget("大牛", "大牛类");

        // 方式一 完成深拷贝
        DeepProtoType p1 = (DeepProtoType) p.clone();

        System.out.println("p.name=" + p.name + " p.deepCloneableTarget=" + p.hashCode());
        System.out.println("p1.name=" + p1.name + " p1.deepCloneableTarget=" + p1.hashCode());

        // 方式二 完成深拷贝
        DeepProtoType p2 = (DeepProtoType) p.deepClone();

        System.out.println("p.name=" + p.name + " p.deepCloneableTarget=" + p.hashCode());
        System.out.println("p2.name=" + p2.name + " p2.deepCloneableTarget=" + p2.hashCode());
    }
}
